// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/base/api/DashboardDeptApi'

import ComClass from '@api/ComQuery'
import DeptDeviceStatusReq from '@api/base/model/DeptDeviceStatusReq'
import DeptWorkOrderChartReq from '@api/base/model/DeptWorkOrderChartReq'
import DeptAlarmChartReq from '@api/base/model/DeptAlarmChartReq'
import DeptPlanPieReq from '@api/base/model/DeptPlanPieReq'
import DeptAreaVideoReq from '@api/base/model/DeptAreaVideoReq'
import DeptGroupOverviewReq from '@api/base/model/DeptGroupOverviewReq'
import DeptEnergyPieReq from '@api/base/model/DeptEnergyPieReq'
import DeptSpareListReq from '@api/base/model/DeptSpareListReq'
import DeptContractListReq from '@api/base/model/DeptContractListReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  async queryDeptDeviceStatus(param, TIP = '设备状态') {
    const req = CORE.grpcDTO(DeptDeviceStatusReq, param)
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptDeviceStatus', req)
    return res
  },

  async queryDeptWorkOrderChart(param = {
    /**
     * @description 时间类型
     * -1日
     * -2周
     * -3月 默认1日
     */
    type: 1,
    /**
     * @description 部门ID
     */
    organId: '',
  }, TIP = '工单统计') {
    const req = CORE.grpcDTO(DeptWorkOrderChartReq, param)
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptWorkOrderChart', req)
    return res
  },

  async queryDeptAlarmChart(param = {
    /**
     * @description 部门ID
     */
    organId: '',
  }, TIP = `${CORE.MAP.ALARM}统计`) {
    const req = CORE.grpcDTO(DeptAlarmChartReq, param)
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptAlarmChart', req)
    return res
  },

  async queryDeptPlanPie(param = {
    /**
     * @description 部门ID
     */
    organId: '',
  }, TIP = '巡检统计') {
    const req = CORE.grpcDTO(DeptPlanPieReq, param)
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptPlanPie', req)
    return res
  },

  async queryDeptAreaVideo(param = {
    /**
     * @description 部门ID
     */
    organId: '',
  }, TIP = '重点区域') {
    const req = CORE.grpcDTO(DeptAreaVideoReq, param)
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptAreaVideo', req)
    return res
  },

  async queryDeptGroupOverview(param = {
    /**
     * @description 部门ID
     */
    organId: '',
  }, TIP = '班组概况') {
    const req = CORE.grpcDTO(DeptGroupOverviewReq, param)
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptGroupOverview', req)
    return res
  },

  async queryDeptEnergyPie(param = {
    /**
     * @description 部门ID
     */
    organId: '',
    /**
     * @description 类型
     * -1能耗统计
     * -2分项用能
     */
    type: 0,
  }, TIP = '能耗统计-分项用能') {
    const req = CORE.grpcDTO(DeptEnergyPieReq, param)
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptEnergyPie', req)
    return res
  },

  async queryDeptSpareList(param = {
    /**
     * 类型
     * -1 全部
     * -2 统计
     * -3 普通分页
     */
    type: 3,
    /**
     * 当前页
     */
    page: 1,
    /**
     * 每页记录数
     */
    pageSize: 10,
    /**
     * 关键字查询
     */
    keyword: '',
    /**
     * 库存状态查询
     * -1正常
     * -2预警
     */
    status: [1, 2],
    /**
     * 租户分区标识
     */
    tenantNo: 0,
    /**
     * 备品分类ID
     */
    spareId: '',
    /**
     * @description 部门ID
     */
    organId: '',
  }, TIP = '库存预警') {
    const req = CORE.grpcDTO(DeptSpareListReq, param, [ComClass, 'comQuery'])
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptSpareList', req)
    return res
  },

  async queryDeptContractList(param = {
    /**
     * 类型
     * -1 全部
     * -2 统计
     * -3 普通分页
     */
    type: 3,
    /**
     * 租户分区标识
     */
    tenantNo: 0,
    /**
     * 当前页
     */
    page: 1,
    /**
     * 每页记录数
     */
    pageSize: 10,
    /**
     * @description 部门ID
     */
    organId: '',
  }, TIP = '合同提醒') {
    const req = CORE.grpcDTO(DeptContractListReq, param, [ComClass, 'comQuery'])
    const res = await CORE.grpc(TIP, CLIENT, 'queryDeptContractList', req)
    return res
  },
}
